#include <QSqlDatabase>
#include "vdatabase.h"

QSqlDatabase& VDataBase::AccountDatabase()
{
	static QSqlDatabase instance;
	static bool s_once = false;
	if (!s_once)
	{
		s_once = true;
		instance = QSqlDatabase::addDatabase("QSQLITE","CONNECTION_ACCOUNT");
		instance.setDatabaseName("AccountDatabase.db");
		instance.open();
	}
	return instance;
}

QSqlDatabase& VDataBase::ContactDatabase()
{
	static QSqlDatabase instance;
	static bool s_once = false;
	if (!s_once)
	{
		s_once = true;
		instance = QSqlDatabase::addDatabase("QSQLITE","CONNECTION_CONTACT");
		instance.setDatabaseName("ContactDatabase.db");
		instance.open();
	}
	return instance;
}

QSqlDatabase& VDataBase::ChatHistoryDatabase()
{
	static QSqlDatabase instance;
	static bool s_once = false;
	if (!s_once)
	{
		s_once = true;
		instance = QSqlDatabase::addDatabase("QSQLITE","CONNECTION_CHATHISTORY");
		instance.setDatabaseName("ChatHistoryDatabase.db");
		instance.open();
	}
	return instance;
}